<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../static/src/xiaoliyu/css/forreg.css">
</head>
<body>
<div class="container">
    <h1>用户注册</h1>
    <form action="http://127.0.0.1:8082/api/auth/register" method="post">
        <label for="name">姓名：</label>
        <input type="text" id="name" name="name" required>
        <label for="phone">手机号：</label>
        <input type="tel" id="phone" name="phone" required>
        <label for="phone">密码：</label>
        <input type="tel" id="password" name="password" required>
        <button type="submit">注册</button>
    </form>
</div>
<script>
    const form = document.getElementById('register-form');
    const registerBtn = document.getElementById('register-btn');

    registerBtn.addEventListener('', function(event) {
        event.preventDefault();
        const name = document.getElementById('name').value;
        const phone = document.getElementById('phone').value;
        const gender = document.querySelector('input[name="gender"]:checked').value;
        const address = document.getElementById('address').value;

        const xhr = new XMLHttpRequest();
        xhr.open('POST', '127.0.0.1:8882/api/auth/login');
        xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
        xhr.onload = function() {
            if (xhr.status === 200) {
                const response = JSON.parse(xhr.responseText);
                console.log(response);
            } else {
                console.error(xhr.statusText);
            }
        };
        xhr.onerror = function() {
            console.error(xhr.statusText);
        };
        const data = JSON.stringify({ name, phone, gender, address });
        xhr.send(data);
    });
</script>
</body>
</html>